package archive;

import java.util.Vector;

import model.Game;

public class GameExample
{
    Vector<double []> d_states;
    Vector<double []> d_rewards; //reward or utility?
    
    byte d_winner;
    
    public GameExample(Game game)
    {

        d_states  = new Vector<double []>();
        d_rewards = new Vector<double []>();
        Vector<byte []> gamebytes = null; //game.getGame(); //TODO:
                
        for(int index = 0; index < gamebytes.size(); ++index) // add targets
        {
            d_states.add(convert(gamebytes.get(0)));
            d_rewards.add(new double[1]);
        }
        d_winner = game.getWinner();
    }
    
    public Vector<Example> getExamplesWithLambdaTargets(double lambda, byte playerColor)
    {
        Vector<Example> examples = new Vector<Example>();
        // 'forthisresult' entail the result for witch the lambda are computed.
        if(playerColor == d_winner)
        {
            for(int index = 0; index < d_rewards.size(); ++index) // add targets
            {
                d_rewards.get(index)[0] = Math.pow(lambda, ((d_rewards.size() - index) - 1));
            }
        }
        
        for(int index = 0; index < d_rewards.size(); ++index) // add targets
        {
            examples.add(new Example(d_states.get(index), d_rewards.get(index)));
        }
        return examples;
    }
    
    private double [] convert(byte [] bytearray)
    {
        double [] doublarray = new double [bytearray.length];
        for(int index = 0; index < bytearray.length; ++index) // add targets
        {
            doublarray[index] = (double)bytearray[index];
        }
        return doublarray;
    }
    
    public String toString()
    {
        String representation = "";
        representation += " " + d_states.size() + " ";
        representation += " " + d_rewards.size() + " ";
        return representation;
        
    }
    
}
